home *** CD-ROM | disk | FTP | other *** search
/ Digital Background Bonanza / Digital Background Bonanza - Disc 1.iso / pc / DBB1.swf / scripts / __Packages / mx / video / VideoPlayer.as < prev   
Encoding:
Text File  |  2007-03-09  |  58.7 KB  |  1,855 lines

  1. class mx.video.VideoPlayer extends MovieClip
  2. {
  3.    var _state;
  4.    var _cachedState;
  5.    var _bufferState;
  6.    var _sawPlayStop;
  7.    var _cachedPlayheadTime;
  8.    var _metadata;
  9.    var _startingPlay;
  10.    var _invalidSeekTime;
  11.    var _invalidSeekRecovery;
  12.    var _currentPos;
  13.    var _atEnd;
  14.    var _cmdQueue;
  15.    var _readyDispatched;
  16.    var _autoResizeDone;
  17.    var _lastUpdateTime;
  18.    var _sawSeekNotify;
  19.    var _updateTimeIntervalID;
  20.    var _updateTimeInterval;
  21.    var _updateProgressIntervalID;
  22.    var _updateProgressInterval;
  23.    var _idleTimeoutIntervalID;
  24.    var _idleTimeoutInterval;
  25.    var _autoResizeIntervalID;
  26.    var _rtmpDoStopAtEndIntervalID;
  27.    var _rtmpDoSeekIntervalID;
  28.    var _httpDoSeekIntervalID;
  29.    var _httpDoSeekCount;
  30.    var _finishAutoResizeIntervalID;
  31.    var _delayedBufferingIntervalID;
  32.    var _delayedBufferingInterval;
  33.    var _isLive;
  34.    var _autoSize;
  35.    var _aspectRatio;
  36.    var _autoPlay;
  37.    var _autoRewind;
  38.    var _bufferTime;
  39.    var _volume;
  40.    var _sound;
  41.    var __visible;
  42.    var _hiddenForResize;
  43.    var _hiddenForResizeMetadataDelay;
  44.    var _contentPath;
  45.    var _video;
  46.    var _ncMgr;
  47.    var _ns;
  48.    var _prevVideoWidth;
  49.    var _prevVideoHeight;
  50.    var _streamLength;
  51.    var _videoWidth;
  52.    var _videoHeight;
  53.    var dispatchEvent;
  54.    var _hiddenRewindPlayheadTime;
  55.    var ncMgrClassName;
  56.    var mc;
  57.    static var version = "1.0.1.10";
  58.    static var shortVersion = "1.0.1";
  59.    static var DISCONNECTED = "disconnected";
  60.    static var STOPPED = "stopped";
  61.    static var PLAYING = "playing";
  62.    static var PAUSED = "paused";
  63.    static var BUFFERING = "buffering";
  64.    static var LOADING = "loading";
  65.    static var CONNECTION_ERROR = "connectionError";
  66.    static var REWINDING = "rewinding";
  67.    static var SEEKING = "seeking";
  68.    static var RESIZING = "resizing";
  69.    static var EXEC_QUEUED_CMD = "execQueuedCmd";
  70.    static var BUFFER_EMPTY = "bufferEmpty";
  71.    static var BUFFER_FULL = "bufferFull";
  72.    static var BUFFER_FLUSH = "bufferFlush";
  73.    static var DEFAULT_INCMANAGER = "mx.video.NCManager";
  74.    static var DEFAULT_UPDATE_TIME_INTERVAL = 250;
  75.    static var DEFAULT_UPDATE_PROGRESS_INTERVAL = 250;
  76.    static var DEFAULT_IDLE_TIMEOUT_INTERVAL = 300000;
  77.    static var AUTO_RESIZE_INTERVAL = 100;
  78.    static var AUTO_RESIZE_PLAYHEAD_TIMEOUT = 0.5;
  79.    static var AUTO_RESIZE_METADATA_DELAY_MAX = 5;
  80.    static var FINISH_AUTO_RESIZE_INTERVAL = 250;
  81.    static var RTMP_DO_STOP_AT_END_INTERVAL = 500;
  82.    static var RTMP_DO_SEEK_INTERVAL = 100;
  83.    static var HTTP_DO_SEEK_INTERVAL = 250;
  84.    static var HTTP_DO_SEEK_MAX_COUNT = 4;
  85.    static var CLOSE_NS_INTERVAL = 0.25;
  86.    static var HTTP_DELAYED_BUFFERING_INTERVAL = 100;
  87.    static var PLAY = 0;
  88.    static var LOAD = 1;
  89.    static var PAUSE = 2;
  90.    static var STOP = 3;
  91.    static var SEEK = 4;
  92.    function VideoPlayer()
  93.    {
  94.       super();
  95.       mx.events.EventDispatcher.initialize(this);
  96.       this._state = mx.video.VideoPlayer.DISCONNECTED;
  97.       this._cachedState = this._state;
  98.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  99.       this._sawPlayStop = false;
  100.       this._cachedPlayheadTime = 0;
  101.       this._metadata = null;
  102.       this._startingPlay = false;
  103.       this._invalidSeekTime = false;
  104.       this._invalidSeekRecovery = false;
  105.       this._currentPos = 0;
  106.       this._atEnd = false;
  107.       this._cmdQueue = new Array();
  108.       this._readyDispatched = false;
  109.       this._autoResizeDone = false;
  110.       this._lastUpdateTime = -1;
  111.       this._sawSeekNotify = false;
  112.       this._updateTimeIntervalID = 0;
  113.       this._updateTimeInterval = mx.video.VideoPlayer.DEFAULT_UPDATE_TIME_INTERVAL;
  114.       this._updateProgressIntervalID = 0;
  115.       this._updateProgressInterval = mx.video.VideoPlayer.DEFAULT_UPDATE_PROGRESS_INTERVAL;
  116.       this._idleTimeoutIntervalID = 0;
  117.       this._idleTimeoutInterval = mx.video.VideoPlayer.DEFAULT_IDLE_TIMEOUT_INTERVAL;
  118.       this._autoResizeIntervalID = 0;
  119.       this._rtmpDoStopAtEndIntervalID = 0;
  120.       this._rtmpDoSeekIntervalID = 0;
  121.       this._httpDoSeekIntervalID = 0;
  122.       this._httpDoSeekCount = 0;
  123.       this._finishAutoResizeIntervalID = 0;
  124.       this._delayedBufferingIntervalID = 0;
  125.       this._delayedBufferingInterval = mx.video.VideoPlayer.HTTP_DELAYED_BUFFERING_INTERVAL;
  126.       if(this._isLive == undefined)
  127.       {
  128.          this._isLive = false;
  129.       }
  130.       if(this._autoSize == undefined)
  131.       {
  132.          this._autoSize = false;
  133.       }
  134.       if(this._aspectRatio == undefined)
  135.       {
  136.          this._aspectRatio = true;
  137.       }
  138.       if(this._autoPlay == undefined)
  139.       {
  140.          this._autoPlay = true;
  141.       }
  142.       if(this._autoRewind == undefined)
  143.       {
  144.          this._autoRewind = true;
  145.       }
  146.       if(this._bufferTime == undefined)
  147.       {
  148.          this._bufferTime = 0.1;
  149.       }
  150.       if(this._volume == undefined)
  151.       {
  152.          this._volume = 100;
  153.       }
  154.       this._sound = new Sound(this);
  155.       this._sound.setVolume(this._volume);
  156.       this.__visible = true;
  157.       this._hiddenForResize = false;
  158.       this._hiddenForResizeMetadataDelay = 0;
  159.       this._contentPath = "";
  160.    }
  161.    function setSize(w, h)
  162.    {
  163.       if(w == this._video._width && h == this._video._height || this._autoSize)
  164.       {
  165.          return undefined;
  166.       }
  167.       this._video._width = w;
  168.       this._video._height = h;
  169.       if(this._aspectRatio)
  170.       {
  171.          this.startAutoResize();
  172.       }
  173.    }
  174.    function setScale(xs, ys)
  175.    {
  176.       if(xs == this._video._xscale && ys == this._video._yscale || this._autoSize)
  177.       {
  178.          return undefined;
  179.       }
  180.       this._video._xscale = xs;
  181.       this._video._yscale = ys;
  182.       if(this._aspectRatio)
  183.       {
  184.          this.startAutoResize();
  185.       }
  186.    }
  187.    function play(url, isLive, totalTime)
  188.    {
  189.       if(url != null && url != undefined)
  190.       {
  191.          if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  192.          {
  193.             this._state = this._cachedState;
  194.          }
  195.          else
  196.          {
  197.             if(!this.stateResponsive)
  198.             {
  199.                this.queueCmd(mx.video.VideoPlayer.PLAY,url,isLive,totalTime);
  200.                return undefined;
  201.             }
  202.             this.execQueuedCmds();
  203.          }
  204.          this._autoPlay = true;
  205.          this._load(url,isLive,totalTime);
  206.          return undefined;
  207.       }
  208.       if(!this.isXnOK())
  209.       {
  210.          if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined)
  211.          {
  212.             throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  213.          }
  214.          this.flushQueuedCmds();
  215.          this.queueCmd(mx.video.VideoPlayer.PLAY);
  216.          this.setState(mx.video.VideoPlayer.LOADING);
  217.          this._cachedState = mx.video.VideoPlayer.LOADING;
  218.          this._ncMgr.reconnect();
  219.          return undefined;
  220.       }
  221.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  222.       {
  223.          this._state = this._cachedState;
  224.       }
  225.       else
  226.       {
  227.          if(!this.stateResponsive)
  228.          {
  229.             this.queueCmd(mx.video.VideoPlayer.PLAY);
  230.             return undefined;
  231.          }
  232.          this.execQueuedCmds();
  233.       }
  234.       if(this._ns == null || this._ns == undefined)
  235.       {
  236.          this._createStream();
  237.          this._video.attachVideo(this._ns);
  238.          this.attachAudio(this._ns);
  239.       }
  240.       switch(this._state)
  241.       {
  242.          case mx.video.VideoPlayer.BUFFERING:
  243.             if(this._ncMgr.isRTMP())
  244.             {
  245.                this._play(0);
  246.                if(this._atEnd)
  247.                {
  248.                   this._atEnd = false;
  249.                   this._currentPos = 0;
  250.                   this.setState(mx.video.VideoPlayer.REWINDING);
  251.                }
  252.                else if(this._currentPos > 0)
  253.                {
  254.                   this._seek(this._currentPos);
  255.                   this._currentPos = 0;
  256.                }
  257.             }
  258.          case mx.video.VideoPlayer.PLAYING:
  259.             return undefined;
  260.          case mx.video.VideoPlayer.STOPPED:
  261.             if(this._ncMgr.isRTMP())
  262.             {
  263.                if(this._isLive)
  264.                {
  265.                   this._play(-1);
  266.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  267.                }
  268.                else
  269.                {
  270.                   this._play(0);
  271.                   if(this._atEnd)
  272.                   {
  273.                      this._atEnd = false;
  274.                      this._currentPos = 0;
  275.                      this._state = mx.video.VideoPlayer.BUFFERING;
  276.                      this.setState(mx.video.VideoPlayer.REWINDING);
  277.                   }
  278.                   else if(this._currentPos > 0)
  279.                   {
  280.                      this._seek(this._currentPos);
  281.                      this._currentPos = 0;
  282.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  283.                   }
  284.                   else
  285.                   {
  286.                      this.setState(mx.video.VideoPlayer.BUFFERING);
  287.                   }
  288.                }
  289.             }
  290.             else
  291.             {
  292.                this._pause(false);
  293.                if(this._atEnd)
  294.                {
  295.                   this._atEnd = false;
  296.                   this._seek(0);
  297.                   this._state = mx.video.VideoPlayer.BUFFERING;
  298.                   this.setState(mx.video.VideoPlayer.REWINDING);
  299.                }
  300.                else if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  301.                {
  302.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  303.                }
  304.                else
  305.                {
  306.                   this.setState(mx.video.VideoPlayer.PLAYING);
  307.                }
  308.             }
  309.             break;
  310.          case mx.video.VideoPlayer.PAUSED:
  311.             this._pause(false);
  312.             if(!this._ncMgr.isRTMP())
  313.             {
  314.                if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  315.                {
  316.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  317.                }
  318.                else
  319.                {
  320.                   this.setState(mx.video.VideoPlayer.PLAYING);
  321.                }
  322.             }
  323.             else
  324.             {
  325.                this.setState(mx.video.VideoPlayer.BUFFERING);
  326.             }
  327.       }
  328.    }
  329.    function load(url, isLive, totalTime)
  330.    {
  331.       if(url == null || url == undefined)
  332.       {
  333.          throw new Error("null url sent to VideoPlayer.load");
  334.       }
  335.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  336.       {
  337.          this._state = this._cachedState;
  338.       }
  339.       else
  340.       {
  341.          if(!this.stateResponsive)
  342.          {
  343.             this.queueCmd(mx.video.VideoPlayer.LOAD,url,isLive,totalTime);
  344.             return undefined;
  345.          }
  346.          this.execQueuedCmds();
  347.       }
  348.       this._autoPlay = false;
  349.       this._load(url,isLive,totalTime);
  350.    }
  351.    function _load(url, isLive, totalTime)
  352.    {
  353.       this._prevVideoWidth = this.videoWidth;
  354.       if(this._prevVideoWidth == undefined)
  355.       {
  356.          this._prevVideoWidth = this._video.width;
  357.          if(this._prevVideoWidth == undefined)
  358.          {
  359.             this._prevVideoWidth = 0;
  360.          }
  361.       }
  362.       this._prevVideoHeight = this.videoHeight;
  363.       if(this._prevVideoHeight == undefined)
  364.       {
  365.          this._prevVideoHeight = this._video.height;
  366.          if(this._prevVideoHeight == undefined)
  367.          {
  368.             this._prevVideoHeight = 0;
  369.          }
  370.       }
  371.       this._autoResizeDone = false;
  372.       this._cachedPlayheadTime = 0;
  373.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  374.       this._sawPlayStop = false;
  375.       this._metadata = null;
  376.       this._startingPlay = false;
  377.       this._invalidSeekTime = false;
  378.       this._invalidSeekRecovery = false;
  379.       this._isLive = isLive != undefined ? isLive : false;
  380.       this._contentPath = url;
  381.       this._currentPos = 0;
  382.       this._streamLength = totalTime;
  383.       this._atEnd = false;
  384.       this._videoWidth = undefined;
  385.       this._videoHeight = undefined;
  386.       this._readyDispatched = false;
  387.       this._lastUpdateTime = -1;
  388.       this._sawSeekNotify = false;
  389.       clearInterval(this._updateTimeIntervalID);
  390.       this._updateTimeIntervalID = 0;
  391.       clearInterval(this._updateProgressIntervalID);
  392.       this._updateProgressIntervalID = 0;
  393.       clearInterval(this._idleTimeoutIntervalID);
  394.       this._idleTimeoutIntervalID = 0;
  395.       clearInterval(this._autoResizeIntervalID);
  396.       this._autoResizeIntervalID = 0;
  397.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  398.       this._rtmpDoStopAtEndIntervalID = 0;
  399.       clearInterval(this._rtmpDoSeekIntervalID);
  400.       this._rtmpDoSeekIntervalID = 0;
  401.       clearInterval(this._httpDoSeekIntervalID);
  402.       this._httpDoSeekIntervalID = 0;
  403.       clearInterval(this._finishAutoResizeIntervalID);
  404.       this._finishAutoResizeIntervalID = 0;
  405.       clearInterval(this._delayedBufferingIntervalID);
  406.       this._delayedBufferingIntervalID = 0;
  407.       this.closeNS(false);
  408.       if(this._ncMgr == null || this._ncMgr == undefined)
  409.       {
  410.          this.createINCManager();
  411.       }
  412.       var _loc2_ = this._ncMgr.connectToURL(this._contentPath);
  413.       this.setState(mx.video.VideoPlayer.LOADING);
  414.       this._cachedState = mx.video.VideoPlayer.LOADING;
  415.       if(_loc2_)
  416.       {
  417.          this._createStream();
  418.          this._setUpStream();
  419.       }
  420.       if(!this._ncMgr.isRTMP())
  421.       {
  422.          clearInterval(this._updateProgressIntervalID);
  423.          this._updateProgressIntervalID = setInterval(this,"doUpdateProgress",this._updateProgressInterval);
  424.       }
  425.    }
  426.    function pause()
  427.    {
  428.       if(!this.isXnOK())
  429.       {
  430.          if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined)
  431.          {
  432.             throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  433.          }
  434.          return undefined;
  435.       }
  436.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  437.       {
  438.          this._state = this._cachedState;
  439.       }
  440.       else
  441.       {
  442.          if(!this.stateResponsive)
  443.          {
  444.             this.queueCmd(mx.video.VideoPlayer.PAUSE);
  445.             return undefined;
  446.          }
  447.          this.execQueuedCmds();
  448.       }
  449.       if(this._state == mx.video.VideoPlayer.PAUSED || this._state == mx.video.VideoPlayer.STOPPED || this._ns == null || this._ns == undefined)
  450.       {
  451.          return undefined;
  452.       }
  453.       this._pause(true);
  454.       this.setState(mx.video.VideoPlayer.PAUSED);
  455.    }
  456.    function stop()
  457.    {
  458.       if(!this.isXnOK())
  459.       {
  460.          if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined)
  461.          {
  462.             throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  463.          }
  464.          return undefined;
  465.       }
  466.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  467.       {
  468.          this._state = this._cachedState;
  469.       }
  470.       else
  471.       {
  472.          if(!this.stateResponsive)
  473.          {
  474.             this.queueCmd(mx.video.VideoPlayer.STOP);
  475.             return undefined;
  476.          }
  477.          this.execQueuedCmds();
  478.       }
  479.       if(this._state == mx.video.VideoPlayer.STOPPED || this._ns == null || this._ns == undefined)
  480.       {
  481.          return undefined;
  482.       }
  483.       if(this._ncMgr.isRTMP())
  484.       {
  485.          if(this._autoRewind && !this._isLive)
  486.          {
  487.             this._currentPos = 0;
  488.             this._play(0,0);
  489.             this._state = mx.video.VideoPlayer.STOPPED;
  490.             this.setState(mx.video.VideoPlayer.REWINDING);
  491.          }
  492.          else
  493.          {
  494.             this.closeNS(true);
  495.             this.setState(mx.video.VideoPlayer.STOPPED);
  496.          }
  497.       }
  498.       else
  499.       {
  500.          this._pause(true);
  501.          if(this._autoRewind)
  502.          {
  503.             this._seek(0);
  504.             this._state = mx.video.VideoPlayer.STOPPED;
  505.             this.setState(mx.video.VideoPlayer.REWINDING);
  506.          }
  507.          else
  508.          {
  509.             this.setState(mx.video.VideoPlayer.STOPPED);
  510.          }
  511.       }
  512.    }
  513.    function seek(time)
  514.    {
  515.       if(this._invalidSeekTime)
  516.       {
  517.          return undefined;
  518.       }
  519.       if(isNaN(time) || time < 0)
  520.       {
  521.          throw new mx.video.VideoError(mx.video.VideoError.INVALID_SEEK);
  522.       }
  523.       if(!this.isXnOK())
  524.       {
  525.          if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined)
  526.          {
  527.             throw new mx.video.VideoError(mx.video.VideoError.NO_CONNECTION);
  528.          }
  529.          this.flushQueuedCmds();
  530.          this.queueCmd(mx.video.VideoPlayer.SEEK,null,false,time);
  531.          this.setState(mx.video.VideoPlayer.LOADING);
  532.          this._cachedState = mx.video.VideoPlayer.LOADING;
  533.          this._ncMgr.reconnect();
  534.          return undefined;
  535.       }
  536.       if(this._state == mx.video.VideoPlayer.EXEC_QUEUED_CMD)
  537.       {
  538.          this._state = this._cachedState;
  539.       }
  540.       else
  541.       {
  542.          if(!this.stateResponsive)
  543.          {
  544.             this.queueCmd(mx.video.VideoPlayer.SEEK,null,false,time);
  545.             return undefined;
  546.          }
  547.          this.execQueuedCmds();
  548.       }
  549.       if(this._ns == null || this._ns == undefined)
  550.       {
  551.          this._createStream();
  552.          this._video.attachVideo(this._ns);
  553.          this.attachAudio(this._ns);
  554.       }
  555.       if(this._atEnd && time < this.playheadTime)
  556.       {
  557.          this._atEnd = false;
  558.       }
  559.       switch(this._state)
  560.       {
  561.          case mx.video.VideoPlayer.PLAYING:
  562.             this._state = mx.video.VideoPlayer.BUFFERING;
  563.          case mx.video.VideoPlayer.BUFFERING:
  564.          case mx.video.VideoPlayer.PAUSED:
  565.             this._seek(time);
  566.             this.setState(mx.video.VideoPlayer.SEEKING);
  567.             break;
  568.          case mx.video.VideoPlayer.STOPPED:
  569.             if(this._ncMgr.isRTMP())
  570.             {
  571.                this._play(0);
  572.                this._pause(true);
  573.             }
  574.             this._seek(time);
  575.             this._state = mx.video.VideoPlayer.PAUSED;
  576.             this.setState(mx.video.VideoPlayer.SEEKING);
  577.       }
  578.    }
  579.    function close()
  580.    {
  581.       this.closeNS(true);
  582.       if(this._ncMgr != null && this._ncMgr != undefined && this._ncMgr.isRTMP())
  583.       {
  584.          this._ncMgr.close();
  585.       }
  586.       this.setState(mx.video.VideoPlayer.DISCONNECTED);
  587.       this.dispatchEvent({type:"close",state:this._state,playheadTime:this.playheadTime});
  588.    }
  589.    function get x()
  590.    {
  591.       return this._x;
  592.    }
  593.    function set x(xpos)
  594.    {
  595.       this._x = xpos;
  596.    }
  597.    function get y()
  598.    {
  599.       return this._y;
  600.    }
  601.    function set y(ypos)
  602.    {
  603.       this._y = ypos;
  604.    }
  605.    function get scaleX()
  606.    {
  607.       return this._video._xscale;
  608.    }
  609.    function set scaleX(xs)
  610.    {
  611.       this.setScale(xs,this.scaleY);
  612.    }
  613.    function get scaleY()
  614.    {
  615.       return this._video._yscale;
  616.    }
  617.    function set scaleY(ys)
  618.    {
  619.       this.setScale(this.scaleX,ys);
  620.    }
  621.    function get width()
  622.    {
  623.       return this._video._width;
  624.    }
  625.    function set width(w)
  626.    {
  627.       this.setSize(w,this._video._height);
  628.    }
  629.    function get height()
  630.    {
  631.       return this._video._height;
  632.    }
  633.    function set height(h)
  634.    {
  635.       this.setSize(this._video._width,h);
  636.    }
  637.    function get videoWidth()
  638.    {
  639.       if(this._readyDispatched)
  640.       {
  641.          this._videoWidth = this._video.width;
  642.       }
  643.       return this._videoWidth;
  644.    }
  645.    function get videoHeight()
  646.    {
  647.       if(this._readyDispatched)
  648.       {
  649.          this._videoHeight = this._video.height;
  650.       }
  651.       return this._videoHeight;
  652.    }
  653.    function get visible()
  654.    {
  655.       if(!this._hiddenForResize)
  656.       {
  657.          this.__visible = this._visible;
  658.       }
  659.       return this.__visible;
  660.    }
  661.    function set visible(v)
  662.    {
  663.       this.__visible = v;
  664.       if(!this._hiddenForResize)
  665.       {
  666.          this._visible = this.__visible;
  667.       }
  668.    }
  669.    function get autoSize()
  670.    {
  671.       return this._autoSize;
  672.    }
  673.    function set autoSize(flag)
  674.    {
  675.       if(this._autoSize != flag)
  676.       {
  677.          this._autoSize = flag;
  678.          if(this._autoSize)
  679.          {
  680.             this.startAutoResize();
  681.          }
  682.       }
  683.    }
  684.    function get maintainAspectRatio()
  685.    {
  686.       return this._aspectRatio;
  687.    }
  688.    function set maintainAspectRatio(flag)
  689.    {
  690.       if(this._aspectRatio != flag)
  691.       {
  692.          this._aspectRatio = flag;
  693.          if(this._aspectRatio && !this._autoSize)
  694.          {
  695.             this.startAutoResize();
  696.          }
  697.       }
  698.    }
  699.    function get autoRewind()
  700.    {
  701.       return this._autoRewind;
  702.    }
  703.    function set autoRewind(flag)
  704.    {
  705.       this._autoRewind = flag;
  706.    }
  707.    function get playheadTime()
  708.    {
  709.       var _loc2_ = !(this._ns == null || this._ns == undefined) ? this._ns.time : this._currentPos;
  710.       if(this._metadata.audiodelay != undefined)
  711.       {
  712.          _loc2_ -= this._metadata.audiodelay;
  713.          if(_loc2_ < 0)
  714.          {
  715.             _loc2_ = 0;
  716.          }
  717.       }
  718.       return _loc2_;
  719.    }
  720.    function set playheadTime(position)
  721.    {
  722.       this.seek(position);
  723.    }
  724.    function get url()
  725.    {
  726.       return this._contentPath;
  727.    }
  728.    function get volume()
  729.    {
  730.       return this._volume;
  731.    }
  732.    function set volume(aVol)
  733.    {
  734.       this._volume = aVol;
  735.       if(!this._hiddenForResize)
  736.       {
  737.          this._sound.setVolume(this._volume);
  738.       }
  739.    }
  740.    function get transform()
  741.    {
  742.       return this._sound.getTransform();
  743.    }
  744.    function set transform(s)
  745.    {
  746.       this._sound.setTransform(s);
  747.    }
  748.    function get isRTMP()
  749.    {
  750.       if(this._ncMgr == null || this._ncMgr == undefined)
  751.       {
  752.          return undefined;
  753.       }
  754.       return this._ncMgr.isRTMP();
  755.    }
  756.    function get isLive()
  757.    {
  758.       return this._isLive;
  759.    }
  760.    function get state()
  761.    {
  762.       return this._state;
  763.    }
  764.    function get stateResponsive()
  765.    {
  766.       switch(this._state)
  767.       {
  768.          case mx.video.VideoPlayer.DISCONNECTED:
  769.          case mx.video.VideoPlayer.STOPPED:
  770.          case mx.video.VideoPlayer.PLAYING:
  771.          case mx.video.VideoPlayer.PAUSED:
  772.          case mx.video.VideoPlayer.BUFFERING:
  773.             return true;
  774.          default:
  775.             return false;
  776.       }
  777.    }
  778.    function get bytesLoaded()
  779.    {
  780.       if(this._ns == null || this._ns == undefined || this._ncMgr.isRTMP())
  781.       {
  782.          return -1;
  783.       }
  784.       return this._ns.bytesLoaded;
  785.    }
  786.    function get bytesTotal()
  787.    {
  788.       if(this._ns == null || this._ns == undefined || this._ncMgr.isRTMP())
  789.       {
  790.          return -1;
  791.       }
  792.       return this._ns.bytesTotal;
  793.    }
  794.    function get totalTime()
  795.    {
  796.       return this._streamLength;
  797.    }
  798.    function get bufferTime()
  799.    {
  800.       return this._bufferTime;
  801.    }
  802.    function set bufferTime(aTime)
  803.    {
  804.       this._bufferTime = aTime;
  805.       if(this._ns != null && this._ns != undefined)
  806.       {
  807.          this._ns.setBufferTime(this._bufferTime);
  808.       }
  809.    }
  810.    function get idleTimeout()
  811.    {
  812.       return this._idleTimeoutInterval;
  813.    }
  814.    function set idleTimeout(aTime)
  815.    {
  816.       this._idleTimeoutInterval = aTime;
  817.       if(this._idleTimeoutIntervalID > 0)
  818.       {
  819.          clearInterval(this._idleTimeoutIntervalID);
  820.          this._idleTimeoutIntervalID = setInterval(this,"doIdleTimeout",this._idleTimeoutInterval);
  821.       }
  822.    }
  823.    function get playheadUpdateInterval()
  824.    {
  825.       return this._updateTimeInterval;
  826.    }
  827.    function set playheadUpdateInterval(aTime)
  828.    {
  829.       this._updateTimeInterval = aTime;
  830.       if(this._updateTimeIntervalID > 0)
  831.       {
  832.          clearInterval(this._updateTimeIntervalID);
  833.          this._updateTimeIntervalID = setInterval(this,"doUpdateTime",this._updateTimeInterval);
  834.       }
  835.    }
  836.    function get progressInterval()
  837.    {
  838.       return this._updateProgressInterval;
  839.    }
  840.    function set progressInterval(aTime)
  841.    {
  842.       this._updateProgressInterval = aTime;
  843.       if(this._updateProgressIntervalID > 0)
  844.       {
  845.          clearInterval(this._updateProgressIntervalID);
  846.          this._updateProgressIntervalID = setInterval(this,"doUpdateProgress",this._updateProgressInterval);
  847.       }
  848.    }
  849.    function get ncMgr()
  850.    {
  851.       if(this._ncMgr == null || this._ncMgr == undefined)
  852.       {
  853.          this.createINCManager();
  854.       }
  855.       return this._ncMgr;
  856.    }
  857.    function get metadata()
  858.    {
  859.       return this._metadata;
  860.    }
  861.    function doUpdateTime()
  862.    {
  863.       var _loc2_ = this.playheadTime;
  864.       switch(this._state)
  865.       {
  866.          case mx.video.VideoPlayer.STOPPED:
  867.          case mx.video.VideoPlayer.PAUSED:
  868.          case mx.video.VideoPlayer.DISCONNECTED:
  869.          case mx.video.VideoPlayer.CONNECTION_ERROR:
  870.             clearInterval(this._updateTimeIntervalID);
  871.             this._updateTimeIntervalID = 0;
  872.       }
  873.       if(this._lastUpdateTime != _loc2_)
  874.       {
  875.          this.dispatchEvent({type:"playheadUpdate",state:this._state,playheadTime:_loc2_});
  876.          this._lastUpdateTime = _loc2_;
  877.       }
  878.    }
  879.    function doUpdateProgress()
  880.    {
  881.       if(this._ns == null || this._ns == undefined)
  882.       {
  883.          return undefined;
  884.       }
  885.       if(this._ns.bytesTotal >= 0 && this._ns.bytesTotal >= 0)
  886.       {
  887.          this.dispatchEvent({type:"progress",bytesLoaded:this._ns.bytesLoaded,bytesTotal:this._ns.bytesTotal});
  888.       }
  889.       if(this._state == mx.video.VideoPlayer.DISCONNECTED || this._state == mx.video.VideoPlayer.CONNECTION_ERROR || this._ns.bytesLoaded == this._ns.bytesTotal)
  890.       {
  891.          clearInterval(this._updateProgressIntervalID);
  892.          this._updateProgressIntervalID = 0;
  893.       }
  894.    }
  895.    function rtmpOnStatus(info)
  896.    {
  897.       if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR)
  898.       {
  899.          return undefined;
  900.       }
  901.       switch(info.code)
  902.       {
  903.          case "NetStream.Play.Stop":
  904.             if(this._startingPlay)
  905.             {
  906.                return undefined;
  907.             }
  908.             switch(this._state)
  909.             {
  910.                case mx.video.VideoPlayer.RESIZING:
  911.                   if(this._hiddenForResize)
  912.                   {
  913.                      this.finishAutoResize();
  914.                   }
  915.                   break;
  916.                case mx.video.VideoPlayer.LOADING:
  917.                case mx.video.VideoPlayer.STOPPED:
  918.                case mx.video.VideoPlayer.PAUSED:
  919.                   break;
  920.                default:
  921.                   this._sawPlayStop = true;
  922.             }
  923.             break;
  924.          case "NetStream.Buffer.Empty":
  925.             if(this._bufferState === mx.video.VideoPlayer.BUFFER_FULL)
  926.             {
  927.                if(this._sawPlayStop)
  928.                {
  929.                   this.rtmpDoStopAtEnd(true);
  930.                }
  931.                else if(this._state == mx.video.VideoPlayer.PLAYING)
  932.                {
  933.                   this.setState(mx.video.VideoPlayer.BUFFERING);
  934.                }
  935.             }
  936.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  937.             this._sawPlayStop = false;
  938.             break;
  939.          case "NetStream.Buffer.Flush":
  940.             if(this._sawSeekNotify && this._state == mx.video.VideoPlayer.SEEKING)
  941.             {
  942.                this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  943.                this._sawPlayStop = false;
  944.                this.setStateFromCachedState();
  945.                this.doUpdateTime();
  946.             }
  947.             if(this._sawPlayStop && (this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY || this._bufferTime <= 0.1 && this._ns.bufferLength <= 0.1))
  948.             {
  949.                this._cachedPlayheadTime = this.playheadTime;
  950.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  951.                this._rtmpDoStopAtEndIntervalID = setInterval(this,"rtmpDoStopAtEnd",mx.video.VideoPlayer.RTMP_DO_STOP_AT_END_INTERVAL);
  952.             }
  953.             var _loc0_ = null;
  954.             if((_loc0_ = this._bufferState) !== mx.video.VideoPlayer.BUFFER_EMPTY)
  955.             {
  956.                if(this._state == mx.video.VideoPlayer.BUFFERING)
  957.                {
  958.                   this.setStateFromCachedState();
  959.                }
  960.             }
  961.             else
  962.             {
  963.                if(!this._hiddenForResize)
  964.                {
  965.                   if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  966.                   {
  967.                      this.setState(mx.video.VideoPlayer.PLAYING);
  968.                   }
  969.                   else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  970.                   {
  971.                      this._cachedState = mx.video.VideoPlayer.PLAYING;
  972.                   }
  973.                }
  974.                this._bufferState = mx.video.VideoPlayer.BUFFER_FLUSH;
  975.             }
  976.             break;
  977.          case "NetStream.Buffer.Full":
  978.             if(this._sawSeekNotify && this._state == mx.video.VideoPlayer.SEEKING)
  979.             {
  980.                this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  981.                this._sawPlayStop = false;
  982.                this.setStateFromCachedState();
  983.                this.doUpdateTime();
  984.             }
  985.             switch(this._bufferState)
  986.             {
  987.                case mx.video.VideoPlayer.BUFFER_EMPTY:
  988.                   this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  989.                   if(!this._hiddenForResize)
  990.                   {
  991.                      if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  992.                      {
  993.                         this.setState(mx.video.VideoPlayer.PLAYING);
  994.                      }
  995.                      else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  996.                      {
  997.                         this._cachedState = mx.video.VideoPlayer.PLAYING;
  998.                      }
  999.                      if(this._rtmpDoStopAtEndIntervalID != 0)
  1000.                      {
  1001.                         this._sawPlayStop = true;
  1002.                         clearInterval(this._rtmpDoStopAtEndIntervalID);
  1003.                         this._rtmpDoStopAtEndIntervalID = 0;
  1004.                      }
  1005.                   }
  1006.                   break;
  1007.                case mx.video.VideoPlayer.BUFFER_FLUSH:
  1008.                   this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  1009.                   if(this._rtmpDoStopAtEndIntervalID != 0)
  1010.                   {
  1011.                      this._sawPlayStop = true;
  1012.                      clearInterval(this._rtmpDoStopAtEndIntervalID);
  1013.                      this._rtmpDoStopAtEndIntervalID = 0;
  1014.                   }
  1015.             }
  1016.             if(this._state == mx.video.VideoPlayer.BUFFERING)
  1017.             {
  1018.                this.setStateFromCachedState();
  1019.             }
  1020.             break;
  1021.          case "NetStream.Pause.Notify":
  1022.             if(this._state == mx.video.VideoPlayer.RESIZING && this._hiddenForResize)
  1023.             {
  1024.                this.finishAutoResize();
  1025.             }
  1026.             break;
  1027.          case "NetStream.Unpause.Notify":
  1028.             if(this._state == mx.video.VideoPlayer.PAUSED)
  1029.             {
  1030.                this._state = mx.video.VideoPlayer.PLAYING;
  1031.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1032.             }
  1033.             else
  1034.             {
  1035.                this._cachedState = mx.video.VideoPlayer.PLAYING;
  1036.             }
  1037.             break;
  1038.          case "NetStream.Play.Start":
  1039.             clearInterval(this._rtmpDoStopAtEndIntervalID);
  1040.             this._rtmpDoStopAtEndIntervalID = 0;
  1041.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1042.             this._sawPlayStop = false;
  1043.             if(this._startingPlay)
  1044.             {
  1045.                this._startingPlay = false;
  1046.                this._cachedPlayheadTime = this.playheadTime;
  1047.             }
  1048.             else if(this._state == mx.video.VideoPlayer.PLAYING)
  1049.             {
  1050.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1051.             }
  1052.             break;
  1053.          case "NetStream.Play.Reset":
  1054.             clearInterval(this._rtmpDoStopAtEndIntervalID);
  1055.             this._rtmpDoStopAtEndIntervalID = 0;
  1056.             if(this._state == mx.video.VideoPlayer.REWINDING)
  1057.             {
  1058.                clearInterval(this._rtmpDoSeekIntervalID);
  1059.                this._rtmpDoSeekIntervalID = 0;
  1060.                if(this.playheadTime == 0 || this.playheadTime < this._cachedPlayheadTime)
  1061.                {
  1062.                   this.setStateFromCachedState();
  1063.                }
  1064.                else
  1065.                {
  1066.                   this._cachedPlayheadTime = this.playheadTime;
  1067.                   this._rtmpDoSeekIntervalID = setInterval(this,"rtmpDoSeek",mx.video.VideoPlayer.RTMP_DO_SEEK_INTERVAL);
  1068.                }
  1069.             }
  1070.             break;
  1071.          case "NetStream.Seek.Notify":
  1072.             if(this.playheadTime != this._cachedPlayheadTime)
  1073.             {
  1074.                this.setStateFromCachedState();
  1075.                this.doUpdateTime();
  1076.             }
  1077.             else
  1078.             {
  1079.                this._sawSeekNotify = true;
  1080.                if(this._rtmpDoSeekIntervalID == 0)
  1081.                {
  1082.                   this._rtmpDoSeekIntervalID = setInterval(this,"rtmpDoSeek",mx.video.VideoPlayer.RTMP_DO_SEEK_INTERVAL);
  1083.                }
  1084.             }
  1085.             break;
  1086.          case "Netstream.Play.UnpublishNotify":
  1087.          case "Netstream.Play.PublishNotify":
  1088.             break;
  1089.          case "NetStream.Play.StreamNotFound":
  1090.             if(!this._ncMgr.connectAgain())
  1091.             {
  1092.                this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1093.             }
  1094.             break;
  1095.          case "NetStream.Play.Failed":
  1096.          case "NetStream.Failed":
  1097.             this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1098.       }
  1099.    }
  1100.    function httpOnStatus(info)
  1101.    {
  1102.       switch(info.code)
  1103.       {
  1104.          case "NetStream.Play.Stop":
  1105.             clearInterval(this._delayedBufferingIntervalID);
  1106.             this._delayedBufferingIntervalID = 0;
  1107.             if(this._invalidSeekTime)
  1108.             {
  1109.                this._invalidSeekTime = false;
  1110.                this._invalidSeekRecovery = true;
  1111.                this.setState(this._cachedState);
  1112.                this.seek(this.playheadTime);
  1113.             }
  1114.             else
  1115.             {
  1116.                switch(this._state)
  1117.                {
  1118.                   case mx.video.VideoPlayer.PLAYING:
  1119.                   case mx.video.VideoPlayer.BUFFERING:
  1120.                   case mx.video.VideoPlayer.SEEKING:
  1121.                      this.httpDoStopAtEnd();
  1122.                }
  1123.             }
  1124.             break;
  1125.          case "NetStream.Seek.InvalidTime":
  1126.             if(this._invalidSeekRecovery)
  1127.             {
  1128.                this._invalidSeekTime = false;
  1129.                this._invalidSeekRecovery = false;
  1130.                this.setState(this._cachedState);
  1131.                this.seek(0);
  1132.             }
  1133.             else
  1134.             {
  1135.                this._invalidSeekTime = true;
  1136.             }
  1137.             break;
  1138.          case "NetStream.Buffer.Empty":
  1139.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1140.             if(this._state == mx.video.VideoPlayer.PLAYING)
  1141.             {
  1142.                clearInterval(this._delayedBufferingIntervalID);
  1143.                this._delayedBufferingIntervalID = setInterval(this,"doDelayedBuffering",this._delayedBufferingInterval);
  1144.             }
  1145.             break;
  1146.          case "NetStream.Buffer.Full":
  1147.          case "NetStream.Buffer.Flush":
  1148.             clearInterval(this._delayedBufferingIntervalID);
  1149.             this._delayedBufferingIntervalID = 0;
  1150.             this._bufferState = mx.video.VideoPlayer.BUFFER_FULL;
  1151.             if(!this._hiddenForResize)
  1152.             {
  1153.                if(this._state == mx.video.VideoPlayer.LOADING && this._cachedState == mx.video.VideoPlayer.PLAYING || this._state == mx.video.VideoPlayer.BUFFERING)
  1154.                {
  1155.                   this.setState(mx.video.VideoPlayer.PLAYING);
  1156.                }
  1157.                else if(this._cachedState == mx.video.VideoPlayer.BUFFERING)
  1158.                {
  1159.                   this._cachedState = mx.video.VideoPlayer.PLAYING;
  1160.                }
  1161.             }
  1162.             break;
  1163.          case "NetStream.Seek.Notify":
  1164.             this._invalidSeekRecovery = false;
  1165.             switch(this._state)
  1166.             {
  1167.                case mx.video.VideoPlayer.SEEKING:
  1168.                case mx.video.VideoPlayer.REWINDING:
  1169.                   if(this._httpDoSeekIntervalID == 0)
  1170.                   {
  1171.                      this._httpDoSeekCount = 0;
  1172.                      this._httpDoSeekIntervalID = setInterval(this,"httpDoSeek",mx.video.VideoPlayer.HTTP_DO_SEEK_INTERVAL);
  1173.                   }
  1174.             }
  1175.             break;
  1176.          case "NetStream.Play.StreamNotFound":
  1177.             this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1178.       }
  1179.    }
  1180.    function ncConnected()
  1181.    {
  1182.       if(this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined)
  1183.       {
  1184.          this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1185.       }
  1186.       else
  1187.       {
  1188.          this._createStream();
  1189.          this._setUpStream();
  1190.       }
  1191.    }
  1192.    function ncReconnected()
  1193.    {
  1194.       if(this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined)
  1195.       {
  1196.          this.setState(mx.video.VideoPlayer.CONNECTION_ERROR);
  1197.       }
  1198.       else
  1199.       {
  1200.          this._ns = null;
  1201.          this._state = mx.video.VideoPlayer.STOPPED;
  1202.          this.execQueuedCmds();
  1203.       }
  1204.    }
  1205.    function onMetaData(info)
  1206.    {
  1207.       if(this._metadata != null)
  1208.       {
  1209.          return undefined;
  1210.       }
  1211.       this._metadata = info;
  1212.       if(this._streamLength == undefined || this._streamLength == null || this._streamLength <= 0)
  1213.       {
  1214.          this._streamLength = info.duration;
  1215.       }
  1216.       if(isNaN(this._videoWidth) || this._videoWidth <= 0)
  1217.       {
  1218.          this._videoWidth = info.width;
  1219.       }
  1220.       if(isNaN(this._videoHeight) || this._videoHeight <= 0)
  1221.       {
  1222.          this._videoHeight = info.height;
  1223.       }
  1224.       this.dispatchEvent({type:"metadataReceived",info:info});
  1225.    }
  1226.    function onCuePoint(info)
  1227.    {
  1228.       if(!this._hiddenForResize || !isNaN(this._hiddenRewindPlayheadTime) && this.playheadTime < this._hiddenRewindPlayheadTime)
  1229.       {
  1230.          this.dispatchEvent({type:"cuePoint",info:info});
  1231.       }
  1232.    }
  1233.    function setState(s)
  1234.    {
  1235.       if(s == this._state)
  1236.       {
  1237.          return undefined;
  1238.       }
  1239.       this._hiddenRewindPlayheadTime = undefined;
  1240.       this._cachedState = this._state;
  1241.       this._cachedPlayheadTime = this.playheadTime;
  1242.       this._state = s;
  1243.       var _loc2_ = this._state;
  1244.       this.dispatchEvent({type:"stateChange",state:_loc2_,playheadTime:this.playheadTime});
  1245.       if(!this._readyDispatched)
  1246.       {
  1247.          switch(_loc2_)
  1248.          {
  1249.             case mx.video.VideoPlayer.STOPPED:
  1250.             case mx.video.VideoPlayer.PLAYING:
  1251.             case mx.video.VideoPlayer.PAUSED:
  1252.             case mx.video.VideoPlayer.BUFFERING:
  1253.                this._readyDispatched = true;
  1254.                this.dispatchEvent({type:"ready",state:_loc2_,playheadTime:this.playheadTime});
  1255.          }
  1256.       }
  1257.       if(this._cachedState === mx.video.VideoPlayer.REWINDING)
  1258.       {
  1259.          this.dispatchEvent({type:"rewind",state:_loc2_,playheadTime:this.playheadTime});
  1260.          if(this._ncMgr.isRTMP() && _loc2_ == mx.video.VideoPlayer.STOPPED)
  1261.          {
  1262.             this.closeNS();
  1263.          }
  1264.       }
  1265.       switch(_loc2_)
  1266.       {
  1267.          case mx.video.VideoPlayer.STOPPED:
  1268.          case mx.video.VideoPlayer.PAUSED:
  1269.             if(this._ncMgr.isRTMP() && this._idleTimeoutIntervalID == 0)
  1270.             {
  1271.                this._idleTimeoutIntervalID = setInterval(this,"doIdleTimeout",this._idleTimeoutInterval);
  1272.             }
  1273.             break;
  1274.          case mx.video.VideoPlayer.SEEKING:
  1275.          case mx.video.VideoPlayer.REWINDING:
  1276.             this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1277.             this._sawPlayStop = false;
  1278.          case mx.video.VideoPlayer.PLAYING:
  1279.          case mx.video.VideoPlayer.BUFFERING:
  1280.             if(this._updateTimeIntervalID == 0)
  1281.             {
  1282.                this._updateTimeIntervalID = setInterval(this,"doUpdateTime",this._updateTimeInterval);
  1283.             }
  1284.          case mx.video.VideoPlayer.LOADING:
  1285.          case mx.video.VideoPlayer.RESIZING:
  1286.             clearInterval(this._idleTimeoutIntervalID);
  1287.             this._idleTimeoutIntervalID = 0;
  1288.       }
  1289.       this.execQueuedCmds();
  1290.    }
  1291.    function setStateFromCachedState()
  1292.    {
  1293.       switch(this._cachedState)
  1294.       {
  1295.          case mx.video.VideoPlayer.PLAYING:
  1296.          case mx.video.VideoPlayer.PAUSED:
  1297.             this.setState(this._cachedState);
  1298.             break;
  1299.          case mx.video.VideoPlayer.BUFFERING:
  1300.             if(this._bufferState == mx.video.VideoPlayer.BUFFER_EMPTY)
  1301.             {
  1302.                this.setState(mx.video.VideoPlayer.BUFFERING);
  1303.             }
  1304.             else
  1305.             {
  1306.                this.setState(this._cachedState);
  1307.             }
  1308.             break;
  1309.          default:
  1310.             this.setState(mx.video.VideoPlayer.STOPPED);
  1311.       }
  1312.    }
  1313.    function createINCManager()
  1314.    {
  1315.       if(this.ncMgrClassName == null || this.ncMgrClassName == undefined)
  1316.       {
  1317.          this.ncMgrClassName = mx.video.VideoPlayer.DEFAULT_INCMANAGER;
  1318.       }
  1319.       var ncMgrConstructor = eval(this.ncMgrClassName);
  1320.       this._ncMgr = new ncMgrConstructor();
  1321.       this._ncMgr.setVideoPlayer(this);
  1322.    }
  1323.    function rtmpDoStopAtEnd(force)
  1324.    {
  1325.       if(this._rtmpDoStopAtEndIntervalID > 0)
  1326.       {
  1327.          switch(this._state)
  1328.          {
  1329.             case mx.video.VideoPlayer.DISCONNECTED:
  1330.             case mx.video.VideoPlayer.CONNECTION_ERROR:
  1331.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  1332.                this._rtmpDoStopAtEndIntervalID = 0;
  1333.                return undefined;
  1334.             default:
  1335.                if(!(force || this._cachedPlayheadTime == this.playheadTime))
  1336.                {
  1337.                   this._cachedPlayheadTime = this.playheadTime;
  1338.                   return undefined;
  1339.                }
  1340.                clearInterval(this._rtmpDoStopAtEndIntervalID);
  1341.                this._rtmpDoStopAtEndIntervalID = 0;
  1342.          }
  1343.       }
  1344.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1345.       this._sawPlayStop = false;
  1346.       this._atEnd = true;
  1347.       this.setState(mx.video.VideoPlayer.STOPPED);
  1348.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1349.       {
  1350.          return undefined;
  1351.       }
  1352.       this.doUpdateTime();
  1353.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1354.       {
  1355.          return undefined;
  1356.       }
  1357.       this.dispatchEvent({type:"complete",state:this._state,playheadTime:this.playheadTime});
  1358.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1359.       {
  1360.          return undefined;
  1361.       }
  1362.       if(this._autoRewind && !this._isLive && this.playheadTime != 0)
  1363.       {
  1364.          this._atEnd = false;
  1365.          this._currentPos = 0;
  1366.          this._play(0,0);
  1367.          this.setState(mx.video.VideoPlayer.REWINDING);
  1368.       }
  1369.       else
  1370.       {
  1371.          this.closeNS();
  1372.       }
  1373.    }
  1374.    function rtmpDoSeek()
  1375.    {
  1376.       if(this._state != mx.video.VideoPlayer.REWINDING && this._state != mx.video.VideoPlayer.SEEKING)
  1377.       {
  1378.          clearInterval(this._rtmpDoSeekIntervalID);
  1379.          this._rtmpDoSeekIntervalID = 0;
  1380.          this._sawSeekNotify = false;
  1381.       }
  1382.       else if(this.playheadTime != this._cachedPlayheadTime)
  1383.       {
  1384.          clearInterval(this._rtmpDoSeekIntervalID);
  1385.          this._rtmpDoSeekIntervalID = 0;
  1386.          this._sawSeekNotify = false;
  1387.          this.setStateFromCachedState();
  1388.          this.doUpdateTime();
  1389.       }
  1390.    }
  1391.    function httpDoStopAtEnd()
  1392.    {
  1393.       this._atEnd = true;
  1394.       if(this._streamLength == undefined || this._streamLength == null || this._streamLength <= 0)
  1395.       {
  1396.          this._streamLength = this._ns.time;
  1397.       }
  1398.       this._pause(true);
  1399.       this.setState(mx.video.VideoPlayer.STOPPED);
  1400.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1401.       {
  1402.          return undefined;
  1403.       }
  1404.       this.doUpdateTime();
  1405.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1406.       {
  1407.          return undefined;
  1408.       }
  1409.       this.dispatchEvent({type:"complete",state:this._state,playheadTime:this.playheadTime});
  1410.       if(this._state != mx.video.VideoPlayer.STOPPED)
  1411.       {
  1412.          return undefined;
  1413.       }
  1414.       if(this._autoRewind)
  1415.       {
  1416.          this._atEnd = false;
  1417.          this._pause(true);
  1418.          this._seek(0);
  1419.          this.setState(mx.video.VideoPlayer.REWINDING);
  1420.       }
  1421.    }
  1422.    function httpDoSeek()
  1423.    {
  1424.       var _loc2_ = this._state == mx.video.VideoPlayer.REWINDING || this._state == mx.video.VideoPlayer.SEEKING;
  1425.       if(_loc2_ && this._httpDoSeekCount < mx.video.VideoPlayer.HTTP_DO_SEEK_MAX_COUNT && (this._cachedPlayheadTime == this.playheadTime || this._invalidSeekTime))
  1426.       {
  1427.          this._httpDoSeekCount = this._httpDoSeekCount + 1;
  1428.          return undefined;
  1429.       }
  1430.       this._httpDoSeekCount = 0;
  1431.       clearInterval(this._httpDoSeekIntervalID);
  1432.       this._httpDoSeekIntervalID = 0;
  1433.       if(!_loc2_)
  1434.       {
  1435.          return undefined;
  1436.       }
  1437.       this.setStateFromCachedState();
  1438.       if(this._invalidSeekTime)
  1439.       {
  1440.          this._invalidSeekTime = false;
  1441.          this._invalidSeekRecovery = true;
  1442.          this.seek(this.playheadTime);
  1443.       }
  1444.       else
  1445.       {
  1446.          this.doUpdateTime();
  1447.       }
  1448.    }
  1449.    function closeNS(updateCurrentPos)
  1450.    {
  1451.       if(this._ns != null && this._ns != undefined)
  1452.       {
  1453.          if(updateCurrentPos)
  1454.          {
  1455.             clearInterval(this._updateTimeIntervalID);
  1456.             this._updateTimeIntervalID = 0;
  1457.             this.doUpdateTime();
  1458.             this._currentPos = this._ns.time;
  1459.          }
  1460.          delete this._ns.onStatus;
  1461.          this._ns.onStatus = null;
  1462.          this._ns.close();
  1463.          this._ns = null;
  1464.       }
  1465.    }
  1466.    function doDelayedBuffering()
  1467.    {
  1468.       switch(this._state)
  1469.       {
  1470.          case mx.video.VideoPlayer.LOADING:
  1471.          case mx.video.VideoPlayer.RESIZING:
  1472.             break;
  1473.          case mx.video.VideoPlayer.PLAYING:
  1474.             clearInterval(this._delayedBufferingIntervalID);
  1475.             this._delayedBufferingIntervalID = 0;
  1476.             this.setState(mx.video.VideoPlayer.BUFFERING);
  1477.             break;
  1478.          default:
  1479.             clearInterval(this._delayedBufferingIntervalID);
  1480.             this._delayedBufferingIntervalID = 0;
  1481.       }
  1482.    }
  1483.    function _pause(doPause)
  1484.    {
  1485.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1486.       this._rtmpDoStopAtEndIntervalID = 0;
  1487.       this._ns.pause(doPause);
  1488.    }
  1489.    function _play()
  1490.    {
  1491.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1492.       this._rtmpDoStopAtEndIntervalID = 0;
  1493.       this._startingPlay = true;
  1494.       switch(arguments.length)
  1495.       {
  1496.          case 0:
  1497.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? 0 : -1,-1);
  1498.             break;
  1499.          case 1:
  1500.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? arguments[0] : -1,-1);
  1501.             break;
  1502.          case 2:
  1503.             this._ns.play(this._ncMgr.getStreamName(),!this._isLive ? arguments[0] : -1,arguments[1]);
  1504.             break;
  1505.          default:
  1506.             throw new Error("bad args to _play");
  1507.       }
  1508.    }
  1509.    function _seek(time)
  1510.    {
  1511.       clearInterval(this._rtmpDoStopAtEndIntervalID);
  1512.       this._rtmpDoStopAtEndIntervalID = 0;
  1513.       if(this._metadata.audiodelay != undefined && time + this._metadata.audiodelay < this._streamLength)
  1514.       {
  1515.          time += this._metadata.audiodelay;
  1516.       }
  1517.       this._ns.seek(time);
  1518.       this._invalidSeekTime = false;
  1519.       this._bufferState = mx.video.VideoPlayer.BUFFER_EMPTY;
  1520.       this._sawPlayStop = false;
  1521.       this._sawSeekNotify = false;
  1522.    }
  1523.    function isXnOK()
  1524.    {
  1525.       if(this._state == mx.video.VideoPlayer.LOADING)
  1526.       {
  1527.          return true;
  1528.       }
  1529.       if(this._state == mx.video.VideoPlayer.CONNECTION_ERROR)
  1530.       {
  1531.          return false;
  1532.       }
  1533.       if(this._state != mx.video.VideoPlayer.DISCONNECTED)
  1534.       {
  1535.          if(this._ncMgr == null || this._ncMgr == undefined || this._ncMgr.getNetConnection() == null || this._ncMgr.getNetConnection() == undefined || !this._ncMgr.getNetConnection().isConnected)
  1536.          {
  1537.             this.setState(mx.video.VideoPlayer.DISCONNECTED);
  1538.             return false;
  1539.          }
  1540.          return true;
  1541.       }
  1542.       return false;
  1543.    }
  1544.    function startAutoResize()
  1545.    {
  1546.       switch(this._state)
  1547.       {
  1548.          case mx.video.VideoPlayer.DISCONNECTED:
  1549.          case mx.video.VideoPlayer.CONNECTION_ERROR:
  1550.             return undefined;
  1551.          default:
  1552.             this._autoResizeDone = false;
  1553.             if(this.stateResponsive && this._videoWidth != undefined && this._videoHeight != undefined)
  1554.             {
  1555.                this.doAutoResize();
  1556.             }
  1557.             else
  1558.             {
  1559.                clearInterval(this._autoResizeIntervalID);
  1560.                this._autoResizeIntervalID = setInterval(this,"doAutoResize",mx.video.VideoPlayer.AUTO_RESIZE_INTERVAL);
  1561.             }
  1562.       }
  1563.    }
  1564.    function doAutoResize()
  1565.    {
  1566.       if(this._autoResizeIntervalID > 0)
  1567.       {
  1568.          switch(this._state)
  1569.          {
  1570.             case mx.video.VideoPlayer.RESIZING:
  1571.             case mx.video.VideoPlayer.LOADING:
  1572.                break;
  1573.             case mx.video.VideoPlayer.DISCONNECTED:
  1574.             case mx.video.VideoPlayer.CONNECTION_ERROR:
  1575.                clearInterval(this._autoResizeIntervalID);
  1576.                this._autoResizeIntervalID = 0;
  1577.                return undefined;
  1578.             default:
  1579.                if(!this.stateResponsive)
  1580.                {
  1581.                   return undefined;
  1582.                }
  1583.                break;
  1584.          }
  1585.          if(!(this._video.width != this._prevVideoWidth || this._video.height != this._prevVideoHeight || this._bufferState == mx.video.VideoPlayer.BUFFER_FULL || this._bufferState == mx.video.VideoPlayer.BUFFER_FLUSH || this._ns.time > mx.video.VideoPlayer.AUTO_RESIZE_PLAYHEAD_TIMEOUT))
  1586.          {
  1587.             return undefined;
  1588.          }
  1589.          if(this._hiddenForResize && this._metadata == null && this._hiddenForResizeMetadataDelay < mx.video.VideoPlayer.AUTO_RESIZE_METADATA_DELAY_MAX)
  1590.          {
  1591.             this._hiddenForResizeMetadataDelay = this._hiddenForResizeMetadataDelay + 1;
  1592.             return undefined;
  1593.          }
  1594.          this._videoWidth = this._video.width;
  1595.          this._videoHeight = this._video.height;
  1596.          clearInterval(this._autoResizeIntervalID);
  1597.          this._autoResizeIntervalID = 0;
  1598.       }
  1599.       if(!this._autoSize && !this._aspectRatio || this._autoResizeDone)
  1600.       {
  1601.          this.setState(this._cachedState);
  1602.          return undefined;
  1603.       }
  1604.       this._autoResizeDone = true;
  1605.       if(this._autoSize)
  1606.       {
  1607.          this._video._width = this._videoWidth;
  1608.          this._video._height = this._videoHeight;
  1609.       }
  1610.       else if(this._aspectRatio)
  1611.       {
  1612.          var _loc3_ = this._videoWidth * this.height / this._videoHeight;
  1613.          var _loc2_ = this._videoHeight * this.width / this._videoWidth;
  1614.          if(_loc2_ < this.height)
  1615.          {
  1616.             this._video._height = _loc2_;
  1617.          }
  1618.          else if(_loc3_ < this.width)
  1619.          {
  1620.             this._video._width = _loc3_;
  1621.          }
  1622.       }
  1623.       if(this._hiddenForResize)
  1624.       {
  1625.          this._hiddenRewindPlayheadTime = this.playheadTime;
  1626.          if(this._state == mx.video.VideoPlayer.LOADING)
  1627.          {
  1628.             this._cachedState = mx.video.VideoPlayer.PLAYING;
  1629.          }
  1630.          if(!this._ncMgr.isRTMP())
  1631.          {
  1632.             this._pause(true);
  1633.             this._seek(0);
  1634.             clearInterval(this._finishAutoResizeIntervalID);
  1635.             this._finishAutoResizeIntervalID = setInterval(this,"finishAutoResize",mx.video.VideoPlayer.FINISH_AUTO_RESIZE_INTERVAL);
  1636.          }
  1637.          else if(!this._isLive)
  1638.          {
  1639.             this._currentPos = 0;
  1640.             this._play(0,0);
  1641.             this.setState(mx.video.VideoPlayer.RESIZING);
  1642.          }
  1643.          else if(this._autoPlay)
  1644.          {
  1645.             clearInterval(this._finishAutoResizeIntervalID);
  1646.             this._finishAutoResizeIntervalID = setInterval(this,"finishAutoResize",mx.video.VideoPlayer.FINISH_AUTO_RESIZE_INTERVAL);
  1647.          }
  1648.          else
  1649.          {
  1650.             this.finishAutoResize();
  1651.          }
  1652.       }
  1653.       else
  1654.       {
  1655.          this.dispatchEvent({type:"resize",x:this._x,y:this._y,width:this._width,height:this._height});
  1656.       }
  1657.    }
  1658.    function finishAutoResize()
  1659.    {
  1660.       clearInterval(this._finishAutoResizeIntervalID);
  1661.       this._finishAutoResizeIntervalID = 0;
  1662.       if(this.stateResponsive)
  1663.       {
  1664.          return undefined;
  1665.       }
  1666.       this._visible = this.__visible;
  1667.       this._sound.setVolume(this._volume);
  1668.       this._hiddenForResize = false;
  1669.       this.dispatchEvent({type:"resize",x:this._x,y:this._y,width:this._width,height:this._height});
  1670.       if(this._autoPlay)
  1671.       {
  1672.          if(this._ncMgr.isRTMP())
  1673.          {
  1674.             if(!this._isLive)
  1675.             {
  1676.                this._currentPos = 0;
  1677.                this._play(0);
  1678.             }
  1679.             if(this._state == mx.video.VideoPlayer.RESIZING)
  1680.             {
  1681.                this.setState(mx.video.VideoPlayer.LOADING);
  1682.                this._cachedState = mx.video.VideoPlayer.PLAYING;
  1683.             }
  1684.          }
  1685.          else
  1686.          {
  1687.             this._pause(false);
  1688.             this._cachedState = mx.video.VideoPlayer.PLAYING;
  1689.          }
  1690.       }
  1691.       else
  1692.       {
  1693.          this.setState(mx.video.VideoPlayer.STOPPED);
  1694.       }
  1695.    }
  1696.    function _createStream()
  1697.    {
  1698.       this._ns = new NetStream(this._ncMgr.getNetConnection());
  1699.       this._ns.mc = this;
  1700.       if(this._ncMgr.isRTMP())
  1701.       {
  1702.          this._ns.onStatus = function(info)
  1703.          {
  1704.             this.mc.rtmpOnStatus(info);
  1705.          };
  1706.       }
  1707.       else
  1708.       {
  1709.          this._ns.onStatus = function(info)
  1710.          {
  1711.             this.mc.httpOnStatus(info);
  1712.          };
  1713.       }
  1714.       this._ns.onMetaData = function(info)
  1715.       {
  1716.          this.mc.onMetaData(info);
  1717.       };
  1718.       this._ns.onCuePoint = function(info)
  1719.       {
  1720.          this.mc.onCuePoint(info);
  1721.       };
  1722.       this._ns.setBufferTime(this._bufferTime);
  1723.    }
  1724.    function _setUpStream()
  1725.    {
  1726.       this._video.attachVideo(this._ns);
  1727.       this.attachAudio(this._ns);
  1728.       if(!isNaN(this._ncMgr.getStreamLength()) && this._ncMgr.getStreamLength() >= 0)
  1729.       {
  1730.          this._streamLength = this._ncMgr.getStreamLength();
  1731.       }
  1732.       if(!isNaN(this._ncMgr.getStreamWidth()) && this._ncMgr.getStreamWidth() >= 0)
  1733.       {
  1734.          this._videoWidth = this._ncMgr.getStreamWidth();
  1735.       }
  1736.       else
  1737.       {
  1738.          this._videoWidth = undefined;
  1739.       }
  1740.       if(!isNaN(this._ncMgr.getStreamHeight()) && this._ncMgr.getStreamHeight() >= 0)
  1741.       {
  1742.          this._videoHeight = this._ncMgr.getStreamHeight();
  1743.       }
  1744.       else
  1745.       {
  1746.          this._videoHeight = undefined;
  1747.       }
  1748.       if((this._autoSize || this._aspectRatio) && this._videoWidth != undefined && this._videoHeight != undefined)
  1749.       {
  1750.          this._prevVideoWidth = undefined;
  1751.          this._prevVideoHeight = undefined;
  1752.          this.doAutoResize();
  1753.       }
  1754.       if(!this._autoSize && !this._aspectRatio || this._videoWidth != undefined && this._videoHeight != undefined)
  1755.       {
  1756.          if(this._autoPlay)
  1757.          {
  1758.             if(!this._ncMgr.isRTMP())
  1759.             {
  1760.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1761.                this._play();
  1762.             }
  1763.             else if(this._isLive)
  1764.             {
  1765.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1766.                this._play(-1);
  1767.             }
  1768.             else
  1769.             {
  1770.                this._cachedState = mx.video.VideoPlayer.BUFFERING;
  1771.                this._play(0);
  1772.             }
  1773.          }
  1774.          else
  1775.          {
  1776.             this._cachedState = mx.video.VideoPlayer.STOPPED;
  1777.             if(this._ncMgr.isRTMP())
  1778.             {
  1779.                this._play(0,0);
  1780.             }
  1781.             else
  1782.             {
  1783.                this._play();
  1784.                this._pause(true);
  1785.                this._seek(0);
  1786.             }
  1787.          }
  1788.       }
  1789.       else
  1790.       {
  1791.          if(!this._hiddenForResize)
  1792.          {
  1793.             this.__visible = this._visible;
  1794.             this._visible = false;
  1795.             this._volume = this._sound.getVolume();
  1796.             this._sound.setVolume(0);
  1797.             this._hiddenForResize = true;
  1798.          }
  1799.          this._hiddenForResizeMetadataDelay = 0;
  1800.          this._play(0);
  1801.          if(this._currentPos > 0)
  1802.          {
  1803.             this._seek(this._currentPos);
  1804.             this._currentPos = 0;
  1805.          }
  1806.       }
  1807.       clearInterval(this._autoResizeIntervalID);
  1808.       this._autoResizeIntervalID = setInterval(this,"doAutoResize",mx.video.VideoPlayer.AUTO_RESIZE_INTERVAL);
  1809.    }
  1810.    function doIdleTimeout()
  1811.    {
  1812.       clearInterval(this._idleTimeoutIntervalID);
  1813.       this._idleTimeoutIntervalID = 0;
  1814.       this.close();
  1815.    }
  1816.    function flushQueuedCmds()
  1817.    {
  1818.       while(this._cmdQueue.length > 0)
  1819.       {
  1820.          this._cmdQueue.pop();
  1821.       }
  1822.    }
  1823.    function execQueuedCmds()
  1824.    {
  1825.       while(this._cmdQueue.length > 0 && (this.stateResponsive || this._state == mx.video.VideoPlayer.CONNECTION_ERROR) && (this._cmdQueue[0].url != null && this._cmdQueue[0].url != undefined || this._state != mx.video.VideoPlayer.DISCONNECTED && this._state != mx.video.VideoPlayer.CONNECTION_ERROR))
  1826.       {
  1827.          var _loc2_ = this._cmdQueue.shift();
  1828.          this._cachedState = this._state;
  1829.          this._state = mx.video.VideoPlayer.EXEC_QUEUED_CMD;
  1830.          switch(_loc2_.type)
  1831.          {
  1832.             case mx.video.VideoPlayer.PLAY:
  1833.                this.play(_loc2_.url,_loc2_.isLive,_loc2_.time);
  1834.                break;
  1835.             case mx.video.VideoPlayer.LOAD:
  1836.                this.load(_loc2_.url,_loc2_.isLive,_loc2_.time);
  1837.                break;
  1838.             case mx.video.VideoPlayer.PAUSE:
  1839.                this.pause();
  1840.                break;
  1841.             case mx.video.VideoPlayer.STOP:
  1842.                this.stop();
  1843.                break;
  1844.             case mx.video.VideoPlayer.SEEK:
  1845.                this.seek(_loc2_.time);
  1846.                break;
  1847.          }
  1848.       }
  1849.    }
  1850.    function queueCmd(type, url, isLive, time)
  1851.    {
  1852.       this._cmdQueue.push({type:type,url:url,isLive:false,time:time});
  1853.    }
  1854. }
  1855.